<div class="primary">
	<div class="yyan">
	Currencies:
	<select id="currency"  name="currency">
		<option id="houbi_USD" value="USD">US Dollar</option>
		<option id="houbi_EUR" value="EUR">Euro</option>
		<option id="houbi_GBP" value="GBP">British Pound</option>
		<option id="houbi_AUD" value="AUD">Australian Dollar</option>
		<option id="houbi_CAD" value="CAD">Canadian Dollar</option>
		<option id="houbi_CHF" value="CHF">Swiss Franc</option>
		<option id="houbi_HKD" value="HKD">Hong Kong Dollar</option>
		<option id="houbi_CNY" value="CNY">Chinese RMB</option>
		<option id="houbi_NZD" value="NZD">New Zealand Dollar</option>
		<option id="houbi_RUB" value="RUB">Russian Ruble</option>
	</select>
	<script>
	$().ready(function(e){
	
		$(".removeStyleInput").live('click',function(e){
			$('#paypal_checkout').submit();
		});
		$("#currency").live('change',function(e){
			$("#currency_code").val($(this).val());
		});
	});
	</script>
	</div>
	
	
	
	
	<div id="shopping_cart-2" class="widget widget_shopping_cart">
		<h3>My shopping cart</h3>
		
		<form id = "paypal_checkout" action = "https://www.paypal.com/cgi-bin/webscr" method = "post">
			<input name = "cmd" value = "_cart" type = "hidden">
			<input name = "upload" value = "1" type = "hidden">
			<input name = "no_note" value = "0" type = "hidden">
			<input name = "bn" value = "PP-BuyNowBF" type = "hidden">
			<input name = "tax" value = "0" type = "hidden">
			<input name = "rm" value = "2" type = "hidden">
		 
			<input name = "business" value = "<?php echo Yii::app()->params['mailpp'];?>" type = "hidden">
			<input name = "handling_cart" value = "0" type = "hidden">
			<input name = "currency_code" value = "USD" type = "hidden" id="currency_code">
			<input name = "lc" value = "GB" type = "hidden">
			<input name = "return" value = "http://<?php echo $_SERVER["SERVER_NAME"];?>" type = "hidden">
			<input name = "cbt" value = "Return to My Site" type = "hidden">
			<input name = "cancel_return" value = "http://<?php echo $_SERVER["SERVER_NAME"];?>" type = "hidden">
			<input name = "custom" value = "" type = "hidden">
			
		<ul class="product_list_widget cart_list ">
		<?php
		$idShoppingCart = "";
		if(Yii::app()->session['listcart'] != null){
			$cnt = 0;
			$total = 0;
			foreach(Yii::app()->session['listcart'] as $key=>$value){
				$cnt++;
				$product = Products::model()->findByPk($value['product_id']);
				$idShoppingCart .= $value['product_id']."-".$value['quantity']."-".$product->price;
				if(!empty($product)) $total += $product->price * $value['quantity'];
				
				$path = "upload_files/products";
				
				$folder_dir = Yii::getPathOfAlias('webroot')."/wwwroot/{$path}/thumb_{$product->image}";
				if (!is_file($folder_dir)) {
					$src = "/uploads/no-image.png";
				} else {
					$src = "/wwwroot/{$path}/thumb_{$product->image}";
				}
		?>
			<input name = "item_name_<?php echo $cnt;?>" value = "<?php echo isset($product->name) ? $product->name : ""?>" type = "hidden">
			<input name = "amount_<?php echo $cnt;?>" value = "<?php echo isset($product->price) ? $product->price : 0?>" type = "hidden">
			<input name = "shipping_<?php echo $cnt;?>" value = "0" type = "hidden">
			
			<li id="lip<?php echo $key;?>">
				<div class = "wd-cls-view-card-left" style="margin-right:20px">
					<a href="<?php echo Yii::app()->createUrl('/products/public', array('alias' => $product->alias));?>" title="<?php echo isset($product->name) ? $product->name : ""?>">
						<img width="119" height="200" src="<?php echo $src?>" class="attachment-shop_thumbnail wp-post-image" alt="<?php echo isset($product->style) ? $product->style : ""?>"  style="width:125px; height:125px"/>
					</a>
				</div>
				<div class = "wd-cls-view-card-left">
					<a href="<?php echo Yii::app()->createUrl('/products/public', array('alias' => $product->alias));?>" title="<?php echo isset($product->name) ? $product->name : ""?>">
						<?php echo isset($product->name) ? $product->name : ""?>
					</a> 
					<p class="from">Quantity: </span><span class="amount">
						
						<input type="button" value="-" id="minus1" class="minus qtyminus" style="margin-right: -4px;"  field='quantity' pid="<?php echo $key;?>" price="<?php echo isset($product->price) ? $product->price : 0?>" limit="<?php echo $product->quantity;?>">
						<input data-min="0" data-max="10"  value="<?php echo $value['quantity'];?>" size="3" name="quantity_<?php echo $cnt;?>" title="Qty" id="quantity<?php echo $key;?>" class="input-text qty text" maxlength="12" />												
						<input type="button" value="+" id="add1" class="plus qtyplus" style="margin-left: -4px;" field='quantity' pid="<?php echo $key;?>" price="<?php echo isset($product->price) ? $product->price : 0?>"  limit="<?php echo $product->quantity;?>">
						
					</p>
					<p class="from">Options: </span><span class="amount"><?php echo $value['os0'];?></p>
					<p class="from">From: </span><span class="amount">&#36;<?php echo isset($product->price) ? $product->price : 0?></p>
					<p class="from">Offer: </span><span class="amount">&#36;<label id="offer<?php echo $key;?>"><?php echo $product->price * $value['quantity'];?></label></p>
				</div>
				<div class = "wd-cls-view-card-right">
					<a href="javascript:void(0);"  title="Delete" class="remove" pid="<?php echo $key;?>">
	              		<img src="<?php echo Yii::app()->request->baseUrl.WWWROOT_FRONTEND;?>/img/icon_trash.gif" alt="delete"  style="width:18px; height:18px"/>
	              	</a>
				</div>
				
			</li>
			
		<?php
			}// end for
			echo '<li class="empty">'.CHtml::link('Clean all',Yii::app()->createUrl('/products/public/cleanAll'),array('class'=>'large buttoncss3 red','style'=>'width:100px')).'</li>';
		$idShoppingCart = md5($idShoppingCart);
		
		?>
		<script>
		$().ready(function(e){
			$('.remove').live('click',function(e){
				$("#lip"+$(this).attr('pid')).fadeOut(500);
				$.get("<?php echo Yii::app()->createUrl('/products/public/remove');?>?pid="+$(this).attr('pid'),function(data){
					window.location.href = window.location.href;
				});
			});	
			
			$("#pa_style").live('change',function(e){
				if($(this).val() != ""){
					$(".reset_variations, .single_variation_wrap").show('slow');
				}
			});
			// This button will increment the value
			$('.qtyplus').live('click',function(e){
				var pid = $(this).attr('pid');
				// Stop acting like a button
				e.preventDefault();
				// Get the field name
				fieldName = $(this).attr('field');
				// Get its current value
				var currentVal = parseInt($("#quantity"+pid).val());
				if(currentVal >= parseInt($(this).attr('limit'))) return false;
				// If is not undefined
				if (!isNaN(currentVal)) {
					// Increment
					$("#quantity"+pid).val(currentVal + 1);
					
				} else {
					// Otherwise put a 0 there
					$("#quantity"+pid).val(0);
				}
				$("#offer"+pid).html($("#quantity"+pid).val() * parseInt($(this).attr('price')));
				$.post("<?php echo Yii::app()->createUrl('/products/public/saveCart');?>?pid="+$(this).attr('pid'),{quantity:$("#quantity"+pid).val()},function(data){
				
				});
			});
			// This button will decrement the value till 0
			$(".qtyminus").live('click',function(e) {
				var pid = $(this).attr('pid');
				// Stop acting like a button
				e.preventDefault();
				// Get the field name
				fieldName = $(this).attr('field');
				// Get its current value
				var currentVal = parseInt($("#quantity"+pid).val());
				// if(currentVal >= parseInt($(this).attr('limit'))) return false;
				if(currentVal == 1 ) return false;
				// If it isn't undefined or its greater than 0
				if (!isNaN(currentVal) && currentVal > 0) {
					
					
					$("#quantity"+pid).val(currentVal - 1);
					
				} else {
					// Otherwise put a 0 there
					$("#quantity"+pid).val(0);
				}
				
				$("#offer"+pid).html($("#quantity"+pid).val() * parseInt($(this).attr('price')));
				$.post("<?php echo Yii::app()->createUrl('/products/public/saveCart');?>?pid="+$(this).attr('pid'),{quantity:$("#quantity"+pid).val()},function(data){
				
				});
			});
			
			
		});
		
		</script>
		<?php
		}else{
			echo '<li class="empty">Shoping cart is empty!</li>';
		}
		
		?>
		</ul>
		
			<input type="submit" name="sbumit" style="display:none" id="submitMyShopping">
		</form>
		
		
		
		
		<div class = "wd-cls-payment-card" style="text-align: right;width: 100%;padding: 20px; font-size:20px; font-weight:bold">
			
				<label>Total Cost</label>
				<span>$<?php echo (isset($total) && !empty($total)) ? $total : 0;?></span>
			

		</div>
		
		
		
		<?php
		
		if(Yii::app()->user->hasFlash('success') && strtolower($type) == "paypal"){
		
		?>
		<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" bgcolor="#dddddd">
			<tbody>
				<tr>
					<td width="16%" height="54" bgcolor="#ffffff">
						<button class="large buttoncss3 red" onclick="window.location.href='<?php echo Yii::app()->createUrl('/boutique');?>';" title="Continue Shopping" type="button"><span><span>Continue Shopping</span></span></button>
					</td>
					<td align="right" valign="bottom" bgcolor="#ffffff">
						<table width="80%" border="0" cellspacing="0" cellpadding="0" style="padding-bottom:6px;border:none">
						  <tbody>
								<tr>
									<td width="38%" align="right" class="removeBorderRB">
									
										<input type="image" class="removeStyleInput" name="submit" src="http://cloud4.faout.com/imagecache/S/images/btn_xpressCheckout.gif" border="0" align="top" alt="PayPal">
										
									</td>
									<td width="5%" align="center" class="removeBorderRB" style="vertical-align: middle;">- OR -</td>								    						
									<td width="9%" align="right" class="removeBorderRB">
									
										<a class="large buttoncss3 green" onclick="$('#trForm').show(500); $('#statusForm').val(1)">Proceed to secure check out</a>
									</td>
								</tr>
							</tbody>
						</table>   
						
					</td>
				</tr>
	
				<tr id="trForm" >
					<td colspan="2">

					<div class="info" style="padding: 20px;color: #282828;background: #91bd09;color: #ffffff;">
						<?php echo Yii::app()->user->getFlash('success'); ?>
					</div>
					
						
						
						<div class="flowBox jiabb" style="border: 1px solid #ebebeb;padding: 20px;">
							<div class="shtitle" entryid="5">
								<h6 style="font-weight: bold;">
									<span>Payment Method</span>
								</h6>
							</div>
							<div style="width:790px; overflow:hidden;">
								<p>Existing PayPal users can complete your payment using your PayPal account.
									New PayPal users can register a PayPal account first, then continue the payment on PayPal website.
								</p>
							</div>
							<input type="image" class="removeStyleInput" name="submit" src="http://cloud4.faout.com/imagecache/S/images/btn_xpressCheckout.gif" border="0" align="top" alt="PayPal">
						</div>
					
					
					
					</td>
				</tr>
			</tbody>
		</table>
		
	
		<?php
		}else{
		?>
		
		
		
		<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" bgcolor="#dddddd">
				<tbody><tr>
					<td width="16%" height="54" bgcolor="#ffffff">
						<button class="large buttoncss3 red" onclick="window.location.href='<?php echo Yii::app()->createUrl('/boutique');?>';" title="Continue Shopping" type="button"><span><span>Continue Shopping</span></span></button>
					</td>
					<td align="right" valign="bottom" bgcolor="#ffffff">
						<table width="80%" border="0" cellspacing="0" cellpadding="0" style="padding-bottom:6px;border:none">
						  <tbody>
								<tr>
									<td width="38%" align="right" class="removeBorderRB">
									
										<input type="image" class="removeStyleInput" name="submit" src="http://cloud4.faout.com/imagecache/S/images/btn_xpressCheckout.gif" border="0" align="top" alt="PayPal">
										
									</td>
									<td width="5%" align="center" class="removeBorderRB" style="vertical-align: middle;">- OR -</td>								    								 <!-- <td width="9%" align="right"><a href="/m-flow-a-checkout.htm?flow=checkout"><img src="http://cloud4.faout.com/imagecache/S/images/place.jpg" border="0"></a></td> -->
									<td width="9%" align="right" class="removeBorderRB">
									
										<a class="large buttoncss3 green" onclick="$('#trForm').show(500); $('#statusForm').val(1)">Proceed to secure check out</a>
									</td>
								</tr>
							</tbody>
						</table>   
						
					</td>
				</tr>
	
				<tr id="trForm" style="<?php echo !empty($_POST['statusForm']) ? "" : "display:none";?>">
					<td colspan="2">
					
					
	
					<?php
					
					
					
						$form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
							'id'=>'wd-form-checkout',
							// 'enableAjaxValidation'=>true,
							'type'=>'horizontal',
							// 'enableClientValidation'=>true,
							// 'clientOptions'=> array(
										// 'validateOnSubmit'=>true,
										// 'validateOnChange'=>false
									// ),
							'htmlOptions' => array(
								'enctype' => 'multipart/form-data',
								'class'		=> 'wd-cls-form-checkout'
						)));
						// dump($form);
						
					?>
					<input type="hidden" name="idShoppingCart" id="idShoppingCart" value="<?php echo $idShoppingCart;?>">
					<input type="hidden" name="statusForm" id="statusForm" value="<?php echo !empty($_POST['statusForm']) ? $_POST['statusForm'] : 0;?>">
					<div class="wd-cls-content-main">
						<div class = "wd-cls-left wd-cls-column">
	
							<div class = "wd-cls-item wd-cls-bottom">
								<div class="wd-input wd-cls-spit-2">
									<?php echo $form->textFieldRow($model,'firstname', array('placeholder'=>ProductsModule::t('Firstname'))); ?>
								</div>
								
								<div class="wd-input wd-cls-spit-2 wd-cls-spit-left">
									<?php echo $form->textFieldRow($model,'lastname', array('placeholder'=>ProductsModule::t('Lastname'))); ?>
								</div>
								<div style = "clear: both;"></div>
								<div class="wd-input">
									<?php echo $form->textFieldRow($model,'address', array('placeholder'=>ProductsModule::t('Address'))); ?>
								</div>
								<div class="wd-input">
									<?php echo $form->textFieldRow($model,'address_line', array('placeholder'=>ProductsModule::t('Address Line 2'))); ?>
								</div>
								<div class="wd-input wd-cls-spit-2">
									<?php echo $form->textFieldRow($model,'city', array('placeholder'=>ProductsModule::t('City'))); ?>
								</div>
								
								<div class="wd-input wd-cls-spit-3 wd-cls-spit-left">
									<?php echo $form->dropDownListRow($model, 'state', $arrStatus, array('class'=>'')); ?>
								</div>
								
								<div class="wd-input wd-cls-spit-3 wd-cls-spit-left">
									<?php echo $form->textFieldRow($model,'zip', array('placeholder'=>ProductsModule::t('Zip'))); ?>
								</div>
							</div>
							
						</div>
						<div class = "wd-cls-center wd-cls-column">
		
							<div class = "wd-cls-item wd-cls-bottom">
								<div class="wd-input">
									<?php echo $form->labelEx($model,'payment', array('class'=>'control-label error required'));?>
									<br>
									<?php
									if(empty($_POST)){
									?>
										<input type="radio" name="CheckOutForm[payment]" value="Check" id="Check" onclick="$('#divEmailPaypal').hide()" checked> Check 
									<?php
									}else{
									?>
									<input type="radio" name="CheckOutForm[payment]" value="Check" id="Check" onclick="$('#divEmailPaypal').hide()" <?php echo (!empty($model->payment) && $model->payment == "Check") ? "checked" : "";?>> Check 
									<?php
									}
									?>
									<br>
									<input type="radio" name="CheckOutForm[payment]" <?php echo (!empty($model->payment) && $model->payment == "Paypal") ? "checked" : "";?> value="Paypal" id="Paypal" onclick="$('#divEmailPaypal').show()"> Paypal 
								</div>
								<div class="wd-input" id="divEmailPaypal" style="display:<?php echo (!empty($model->payment) && $model->payment == "Paypal") ? "block" : "none";?>">
									<?php echo $form->textFieldRow($model,'emailPaypal', array('placeholder'=>ProductsModule::t('Payment email'))); ?>
								</div>
								<div class="wd-input">
									<?php echo $form->textFieldRow($model,'email', array('placeholder'=>ProductsModule::t('Your Personal Email Address'))); ?>
								</div>
								
								<div class="wd-input">
									<?php echo $form->textFieldRow($model,'phone', array('placeholder'=>ProductsModule::t('Reachable Phone'))); ?>
								</div>
								
								<div class="wd-input wd-area">
									<?php echo $form->textAreaRow($model,'message',array('class'=>'span10', 'rows'=>5));?>
								</div>
							</div>
							<div class = "wd-cls-item wd-cls-bottom">
								<div class="wd-input wd-cls-checkboxlist">
									<?php echo $form->checkBoxListRow($model, 'term', $arrTermsConditions);?>
									
								</div>
							</div>
							
							<div class = "wd-cls-action-continue">
								<input type = "submit" value = "Continue" class="large buttoncss3 green"/>
								<div class = "wd-cls-description-italic">Your FREE UPS shipping label will be waiting!</div>
							</div>
						</div>
						

						<div style = "clear: both;"></div>
						
						
					</div>

					<?php
					$this->endWidget();
					
					?>
					
					</td>
				</tr>
				<tr>
					<td height="47" colspan="2" bgcolor="#FFF4F4" style="padding:5px;"><span class="bone" style=" line-height:14px; color:#666666">Notice: Shipping cost estimation is based on lowest-cost available shipping methods. We encourage you to try and place orders, it's best way to get accurate shipping cost and find out detail payment method. Please feel free to contact our customer representative if you have any questions.</span></td>
				</tr>
			</tbody></table>
		
		
		
		<?php
		}
		?>
		
		
			
		

		<!--<ul class="cart_list product_list_widget ">
			<li class="empty">No products in the cart.</li>
		</ul>-->
	</div>
</div>

<style type = "text/css">
	/** View Card **/
	.primary .widget_shopping_cart li .wd-cls-view-card-left{float: left;}
	.primary .widget_shopping_cart li .wd-cls-view-card-right{float: right;}
	.primary .widget_shopping_cart li .wd-cls-view-card-right img{display: block;width: 120px;height: 100px;}
	.widget_shopping_cart ul.cart_list {border: 1px solid rgba(0,0,0,0.1);}
	.wd-cls-payment-card{width: 35%;float: right;overflow: hidden;}
	
	.wd-cls-payment-card .wd-cls-view-card-left{float: left;padding-top: 17px;}
	.wd-cls-payment-card .wd-cls-view-card-right{float: right;width: 108px;overflow: hidden;}
	.wd-cls-payment-card .wd-cls-view-card-left label{margin-right: 10px;font-size: 14px;font-weight: bold;}
	.wd-cls-payment-card .wd-cls-view-card-left span{font-size: 14px;font-weight: bold;}
	/** End **/
	
	.removeBorderRB{
		border-right: none;
		border-bottom: none
	}
	.removeStyleInput{
		-webkit-box-shadow:none;
		border:none;
		background:none;
	}
	.wd-cls-bottom{float:left;width:50%}
	.wd-cls-bottom input[type=text],.wd-cls-bottom textarea{width:90%}
	label.required{color:#333}
	span.required{color:red;}
	span.error{color:red;width:100%;float:left}
</style>
